package com.zheng.russiaRec.controller.initGame 
{
	import com.zheng.russiaRec.controller.C_AddScore;
	import com.zheng.russiaRec.controller.C_CheckFiexd;
	import com.zheng.russiaRec.controller.C_ClearGroup;
	import com.zheng.russiaRec.controller.C_CreateGroup;
	import com.zheng.russiaRec.controller.C_GamePause;
	import com.zheng.russiaRec.controller.C_GameResume;
	import com.zheng.russiaRec.controller.C_MoveGroup;
	import com.zheng.russiaRec.controller.C_RotationGroup;
	import com.zheng.russiaRec.controller.MC_DropStrong;
	import com.zheng.russiaRec.controller.MC_MoveGroup;
	import com.zheng.russiaRec.controller.MC_RotationGroup;
	import com.zheng.russiaRec.model.P_App;
	import com.zheng.russiaRec.model.P_Checkerboard;
	import com.zheng.russiaRec.model.vo.VO_App;
	import com.zheng.russiaRec.model.vo.VO_Checkerboard;
	import com.zheng.russiaRec.staticData.EventData;
	import com.zheng.russiaRec.view.M_App;
	import com.zheng.russiaRec.view.M_Checkerboard;
	import com.zheng.russiaRec.view.components.UI_Checkerboard;
	
	import org.puremvc.as3.interfaces.ICommand;
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.command.SimpleCommand;
	
	
	
	/**
	 * 启动
	 * @author Mr.zheng
	 */
	public class C_StartUp extends SimpleCommand implements ICommand
	{	
		//app proxy 对象
		private var proxyAppObj:Object = new Object();
		//棋盘 proxy  对象
		private var proxyCbObj:Object = new Object();
		
		//app mediator 对象
		private var mediatorAppObj:Object = new Object();
		//棋盘 Mediator 对象
		private var mediatorCbObj:Object=new Object();
		//键盘 Mediator 对象
		private var mediatorKbObj:Object=new Object();
		
		/* INTERFACE org.puremvc.as3.interfaces.ICommand */
		
		override public function execute(notification:INotification):void
		{
			regProxy();
			regCommand();
			regMediator(notification);
			
			sendNotification(ApplicationFacade.START_OVER);
			facade.removeCommand(ApplicationFacade.START_UP);
		}
		//注册proxy
		private function regProxy():void {
			//注册app proxy
			proxyAppObj = new Object();
			var vo_app:VO_App = new VO_App();
			proxyAppObj.vo_app = vo_app;
			facade.registerProxy(new P_App(proxyAppObj));
			//注册棋盘proxy
			var vo_checkerboard:VO_Checkerboard = new VO_Checkerboard();
			proxyCbObj.vo_checkerboard = vo_checkerboard;
			facade.registerProxy(new P_Checkerboard(proxyCbObj));
		}
		//注册modiator
		private function regMediator(notification:INotification):void {
			//注册app mediator
			mediatorAppObj.appRoot = notification.getBody();
			facade.registerMediator(new M_App(mediatorAppObj));
			//注册棋盘Mediator
			var ui_cb:UI_Checkerboard=new UI_Checkerboard();
			mediatorCbObj.ui_cb=ui_cb;
			facade.registerMediator(new M_Checkerboard(mediatorCbObj));
		}
		//注册command
		private function regCommand():void {
			facade.registerCommand(EventData.P_BRICK_CREATED, C_CreateGroup);					//注册command 创建group
			facade.registerCommand(EventData.MC_BRICK_MOVE, MC_MoveGroup);						//宏，移动积木
			facade.registerCommand(EventData.MC_BRICK_ROTAION, MC_RotationGroup);				//宏，旋转积木
			facade.registerCommand(EventData.M_BRICK_MOVE, C_MoveGroup);						//移动积木
			facade.registerCommand(EventData.M_BRICK_ROTATION, C_RotationGroup);				//旋转积木
			facade.registerCommand(EventData.M_BRICL_CLEAR, C_ClearGroup);						//清理group数据
			facade.registerCommand(EventData.M_BRICK_CHECK_FIXED, C_CheckFiexd);				//检测是否有可消除的行
			facade.registerCommand(EventData.C_DEL_LINE, C_AddScore);							//加分
			facade.registerCommand(EventData.M_GAME_PAUSE,C_GamePause);							//游戏暂停
			facade.registerCommand(EventData.M_GAME_RESUME, C_GameResume);						//游戏恢复
			facade.registerCommand(EventData.MC_DROP_STRONG, MC_DropStrong);					//狠狠落下
		}
	}

}